package com.itheima.controller;

import com.itheim.client.pojo.Dish;
import com.itheima.common.R;
import com.itheima.service.CDishService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author longbosheng
 * @Date 2022/6/19 18:59
 * @PackageName:com.itheima.controller
 * @ClassName: DishController
 * @Description: TODO
 * @Version 1.0
 */
@Log4j2
@RestController
@RequestMapping("/dish")
public class DishController {
    @Autowired
    private CDishService cdishService;
    /**
     * 菜品列表
     * @return
     */
    @GetMapping("/list")
    public R dishList(String categoryId,int status){
        /*添加条件*/
        List<Dish> dishlist = cdishService.dishList(categoryId, status);
        if (dishlist!=null){
            return R.success(dishlist);
        }
        else {
            return R.error("菜品列表出错了！");
        }
    }
}
